@extends("layouts.app",['categories'=>get_categoires_all()])

@section('title','个人中心 - '.$user->name.' - 编辑')

@section('content')
    <div class="row">


        <div class="col-md-8 offset-md-2">

            <div class="card">
                <div class="card-header">
                   <h5 class="pt-2 text-center"><i class="fa-solid fa-user-pen"></i>
                       资料编辑</h5>
                </div>
                <div class="card-body">
                    <form action="{{route('users.update',Auth::id())}}" method="post" enctype="multipart/form-data">
                        @csrf
                        {{method_field('PUT')}}
                        @include('utils._errors')
                        <div class="mb-3">
                            <label for="name" class="form-label">用户名</label>
                            <input type="text" name="name" class="form-control" id="name" value="{{old('name',$user->name)}}" placeholder="当前用户名">
                        </div>
                        <div class="mb-3">
                            <label for="email" class="form-label">邮箱</label>
                            <input type="email" class="form-control" name="email" readonly id="email" value="{{$user->email}}" placeholder="禁止修改">
                        </div>

                        <div class="mb-3">
                            <label for="info" class="form-label">个人简介</label>
                            <textarea class="form-control" id="info" name="info" rows="3">{{old('info',$user->info)}}</textarea>
                        </div>

                        <div class="mb-3">
                            <label for="avatar" class="form-label">头像</label>
                            <input class="form-control" name="avatar" type="file" id="avatar">
                        </div>

                        @if($user->avatar)
                            <img src={{get_user_avatar($user->avatar)}} alt="avatar" width="200" class="img-thumbnail"/>
                        @endif

                        <div class="mb-3 text-center">
                            <button type="submit" class="btn btn-primary">
                                提交
                            </button>
                        </div>

                    </form>
                </div>

            </div>


        </div>


    </div>



@stop
